﻿using System.Diagnostics.CodeAnalysis;
using Mono.Linker.Tests.Cases.Expectations.Assertions;
using Mono.Linker.Tests.Cases.Expectations.Metadata;

namespace Mono.Linker.Tests.Cases.DynamicDependencies
{
    [KeptMemberInAssembly("library.dll", "Mono.Linker.Tests.Cases.DynamicDependencies.Dependencies.DynamicDependencyMethodInAssemblyLibrary", ".ctor()")]
    [KeptMemberInAssembly("library.dll", "Mono.Linker.Tests.Cases.DynamicDependencies.Dependencies.DynamicDependencyMethodInAssemblyLibrary", "privateField")]
    [SetupCompileBefore("library.dll", new[] { "Dependencies/DynamicDependencyMethodInAssemblyLibrary.cs" })]
    [SetupLinkerArgument("--skip-unresolved", "true")]
    public class DynamicDependencyMethodInAssembly
    {
        public static void Main()
        {
            Dependency();
        }

        [Kept]
        [DynamicDependency("#ctor()", "Mono.Linker.Tests.Cases.DynamicDependencies.Dependencies.DynamicDependencyMethodInAssemblyLibrary", "library")]
        [DynamicDependency(DynamicallyAccessedMemberTypes.NonPublicFields, "Mono.Linker.Tests.Cases.DynamicDependencies.Dependencies.DynamicDependencyMethodInAssemblyLibrary", "library")]

        [ExpectedWarning("IL2035", "NonExistentAssembly")]
        [DynamicDependency("method", "type", "NonExistentAssembly")]
        static void Dependency()
        {
        }
    }
}
